<{include file="public/header.html"}> 
	<!--问答 搜索-->
	<header class="bj-white search-page follow-head">
            <a href="javascript:;" onclick="javascript:history.back(-1);" class="icon-return iconfont iconfont-top iconfont-left col-red"></a>
			<h1 class="bar-title">搜索结果</h1>
	</header>
	<!--搜索提示-->
	<div class="wd-search mt50">
		<div class="tip ptb10 plr15 f-cb">
                    <!--<a href="<{eval url('wenda/asking')}>" class="fr bj-red">我要提问</a>-->
			<p>“<span class="col-red search-tag"><{$keyword}></span>”有关的所有问题</p>
		</div>
            <input type="hidden" class="search-box search-text" value="<{$keyword}>" data-search-val="<{$keyword}>">
	</div>
	<!--搜索结果-->
        <div class="mb60">
            <ul class="wd-search-list" id="content-list">
                <{foreach from=$list item=val}>
                <li class="ptb10 plr15 border-bottom-lg">
                        <button class="iconfont fr mt5 col-grey999"><i><{$val['focusnum']}></i>&#xe654;</button>
                        <a href="<{$val['space_url']}>" class="user-head f-cb disblock">
                                <img src="<{$val['head_img']}>" class="head fl"/>
                                <span class="name fl ml5"><{$val['nickname']}></span>
                                <img src="<{$style_dir}>/img/vip/vip1.png" class="badge fl ml5"/>
                        </a>
                        <a href="<{$val['detail_url']}>" class="disblock mt5">
                            <!--搜索出来只显示标题-->
                            <p class="txt pb5"><{$val['title']}></p>
                            <font class="iconfont col-grey999">&#xe675;<i><{$val['answernum']}></i></font>
                            <font class="iconfont col-grey999 ml5">&#xe60a;<i><{$val['readnum']}></i></font>
                            <p class="time fr"><{$val['create_time']}></p>
                        </a>
                </li>
                <{/foreach}>
            </ul>
            <div class="loading" id="noresults" <{if $list}> style="display: none;"<{/if}>>
                <a href="javascript:;" class="load-success empty-load">
                    <img src="<{$style_dir}>/img/none/none3.jpg">
                    <p>找不到相关内容了</p>
                    <p class="col-greyccc mt5">亲亲，换个关键词试试吧</p>
                </a>
            </div>
            <div class="loading" id="loading"  style="display: none;">
                <a class="/*pull-load*/ load-success" href="javascript:;">加载中...</a>
            </div>
            <div class="loading" id="nomoreresults" style="display: none;">
                <a href="javascript:;" class="load-success nomore-load">已经到底啦~~~</a>
            </div>
        </div>
	<{include file="public/footer_banner.html"}> 
        <script type="text/javascript" src="/static/js/scrollpagination.js"></script>
        <script type="text/javascript">
            $(function(){
                var currentPage = 0;
                $('#content-list').scrollPagination({
                    'contentPage': "/ajax/ajax_search_more_wenda_json",
                    'contentData': {
                        'keyWord': $(".search-text").attr("data-search-val"),
                        'pageIndex': currentPage
                    },
                    'scrollTarget': $(window),
                    'heightOffset': 0,
                    'beforeLoad': function() { // before load function, you can display a preloader div
                        $('#loading').fadeIn('fast');
                        $('#loading').attr('scrollpagination','disabled');
                    },
                    'afterLoad': function(elementsLoaded) { // after loading content, you can use this function to animate your new elements
                        $('#loading').fadeOut('fast');
                        $('#loading').attr('scrollpagination','enabled');                           
                        if (elementsLoaded.length == 0) {
                            $('#nomoreresults').fadeIn('slow');
                            $('#content-list').stopScrollPagination();
                        }else{
                            currentPage = currentPage + 1;
                        }
                        if($('#content-list').children().length == 0){
                            $('#nomoreresults').hide();
                        }
                        this.contentData.pageIndex = currentPage;
                        $(elementsLoaded).fadeInWithDelay();
                        if ($('#content-list').children().length > 100) { // if more than 100 results already loaded, then stop pagination (only for testing)
                            $('#nomoreresults').fadeIn();
                            $('#content-list').stopScrollPagination();
                        };
                    }
                });     
                $.fn.fadeInWithDelay = function() {
                    var delay = 0;
                    return this.each(function() {
                        $(this).delay(delay).animate({
                            opacity: 1
                        }, 200);
                        delay += 100;
                    });
                }; 
                //文章关键词搜索
                var load_false = true;
                $("#wenda-search-btn").on("click",function(){
                    if(!load_false){return;}
                    var _box = $("#search-text"),_text=_box.val();
                    if($.trim(_text) == ""){
                        $.mvalidateTip("请输入查询关键字");return;
                    }
                    _box.attr("data-search-val",_text);
                    layer.open({type:2});$(".search-tag").text(_text);
                    doRequest("/ajax/ajax_search_wenda_json",{keyWord:_text},true,function(data){
                        load_false = true;
                        layer.closeAll();
                        if(data.htmlData == ""){
                            $('#noresults').fadeIn();
                            $('#nomoreresults').hide();
                        }else{
                            $('#noresults').hide();
                        }
                        return $("#content-list").html(data.htmlData).attr("scrollpagination","enabled");
                    },function(data){});
                });
            });
        </script>
<{include file="public/footer.html"}> 
